{% extends "hs-base.html" %}
{% block div %}

    <div class="content">
                    <div class="container-fluid">

                        <div class="row">
                            <div class="col-12">
                                <div class="card-box">
                                    <h4 class="m-t-0 header-title">环境信息</h4>
                                    <p class="text-muted m-b-30 font-13">
                                        显示所有环境信息
                                    </p>

                                    <div class="mb-3">
                                        <div class="row">
                                            <div class="col-12 text-sm-center form-inline">
                                                <div class="form-group mr-2">
                                                    <select id="demo-foo-filter-status" class="custom-select">
                                                        <option value="">显示所有</option>
                                                        <option value="active">开启</option>
                                                        <option value="disabled">停止</option>
                                                        <option value="suspended">升级中</option>
                                                    </select>
                                                </div>
                                                <div class="form-group">
                                                    <input id="demo-foo-search" type="text" placeholder="Search" class="form-control" autocomplete="on">
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <table id="demo-foo-filtering" class="table table-striped table-bordered toggle-circle m-b-0" data-page-size="7">
                                        <thead>
                                        <tr>
                                            <th data-hide="phone">环境名称</th>
                                            <th data-hide="phone">申请日期</th>
                                            <th data-hide="phone, tablet">申请人</th>
                                            <th data-hide="phone, tablet" class="text-center">审批类型</th>
                                        </tr>
                                        </thead>
                                        <tbody>

                                        {% for server_list in server_lists %}
                                            <tr>
                                                <td>{{ server_list[0] }}</td>
                                                <td>{{ server_list[1] }}</td>
                                                <td>{{ server_list[2] }}</td>
                                                <td class="text-center">
                                                    <button name="{{ server_list[3] }}" onclick="readonly_apply(this)" class="btn btn-sm btn-icon"><i class="mdi mdi-view-grid"></i> 只读权限</button>
                                                    <button name="{{ server_list[3] }}" onclick="edit_apply(this)" class="btn btn-sm btn-icon"><i class="mdi mdi-view-grid"></i> 修改权限</button>
                                                    <button name="{{ server_list[3] }}" onclick="refuse_apply(this)" class="btn btn-sm btn-icon"><i class="mdi mdi-view-grid"></i> 拒绝申请</button>
                                                </td>
                                            </tr>
                                        {% endfor %}

                                        </tbody>
                                        <tfoot>
                                        <tr class="active">
                                            <td colspan="6">
                                                <div class="text-right">
                                                    <ul class="pagination pagination-split justify-content-end footable-pagination m-t-10 m-b-0"></ul>
                                                </div>
                                            </td>
                                        </tr>
                                        </tfoot>
                                    </table>
                                </div>
                            </div>
                        </div>

                        <!-- end row -->

                    </div> <!-- container -->

                </div>

{% endblock %}
{% block script %}
    <script type="text/javascript">
        function readonly_apply(obj) {
            var getName = {IdName : obj.name,fun : 'readonly'}
            if(confirm("是否同意赋予只读权限？")){
                $.ajax({
                type:'POST',
                data:getName,
                success:function (data) {
                    alert(data);
                    window.location.reload();
                },
                error:function () {
                    alert("审批失败")

                }

                })
            }




        }
        function edit_apply(obj) {
            var getName = {IdName : obj.name, fun:'edit'}
            if(confirm("是否同意赋予修改权限？")){
                $.ajax({
                type:'POST',
                data:getName,
                url:"http://127.0.0.1:5000/approval?y",
                success:function (data) {
                    alert(data);
                    window.location.reload();
                },
                error:function () {
                    alert("审批失败")

                }

                })
            }




        }
        function refuse_apply(obj) {
            var getName = {IdName : obj.name, fun:'refuse'}
            if(confirm("是否拒绝申请？")){
                $.ajax({
                type:'POST',
                data:getName,
                url:"http://127.0.0.1:5000/approval?z",
                success:function (data) {
                    alert(data);
                    window.location.reload();
                },
                error:function () {
                    alert("审批失败")

                }

                })
            }




        }

    </script>
{% endblock %}